import 'dart:io';

import 'package:device_info_plus/device_info_plus.dart';
import 'package:flutter/services.dart';
import 'package:package_info_plus/package_info_plus.dart';

class DevicesUtils {
  static Future<String> getBuildNo() async {
    final PackageInfo packageInfo = await PackageInfo.fromPlatform();
    return packageInfo.buildNumber;
  }

  static Future<String> getVersion() async {
    final PackageInfo packageInfo = await PackageInfo.fromPlatform();
    return packageInfo.version;
  }

  static Future<String> getPackageName() async {
    final PackageInfo _packageInfo = await PackageInfo.fromPlatform();
    return _packageInfo.packageName;
  }

  static getDeviceInfo() async {
    final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
    try {
      if (Platform.isAndroid) {
        AndroidDeviceInfo deviceData = await deviceInfoPlugin.androidInfo;
        return deviceData;
      } else if (Platform.isIOS) {
        IosDeviceInfo deviceData = await deviceInfoPlugin.iosInfo;
        return deviceData;
      }
    } on PlatformException {
      return null;
    }
  }
}
